#include<iostream>
#include<stdlib.h>
using namespace std;
class Date{
      private:
              int Ngay, Thang, Nam;
      public:
             Date();
             Date(int, int, int);
             void Nhap();
             void In();
             int HopLe();
             Date Cong();
             Date Cong(int);
};
Date::Date(){
             Ngay=Thang=Nam=1;             
}
Date::Date(int a, int b, int c){
               Ngay=a; Thang=b; Nam=c;
}
void Date::Nhap(){
     cout<<"Nhap ngay: "; cin>>Ngay;
     cout<<"Nhap thang: "; cin>>Thang;
     cout<<"Nhap nam: "; cin>>Nam;
}
void Date::In(){
          cout<<Ngay<<"/"<<Thang<<"/"<<Nam;
}
int Date::HopLe(){
int kq=1;
    switch (Thang) {
           case 1:
           case 3:
           case 5:
           case 7:
           case 8:
           case 10:
           case 12:  if(Ngay<=0||Ngay>31)  kq=0; break;
           case 4:
           case 6:
           case 9:
           case 11:  if(Ngay<=0||Ngay>30)  kq=0; break;
           case 2: if(Nam%4==0) {if(Ngay<=0||Ngay>29)  kq=0;}
                   else if(Ngay<=0||Ngay>28)  kq=0; break;
           default: kq=0; break;
    };
    return kq;    
}
Date Date::Cong(){
               switch (Thang) {
                   case 1:
                   case 3:
                   case 5:
                   case 7:
                   case 8:
                   case 10:  
                        {if(Ngay==31) {Ngay=1; Thang+=1;}
                         else Ngay+=1; break;};
                   case 12:   
                        {if(Ngay==31) {Ngay=1; Thang=1; Nam+=1;} else Ngay+=1; break;};         
                   case 4:
                   case 6:
                   case 9:
                   case 11:
                        {if(Ngay==30) {Ngay=1; Thang+=1;}
                         else Ngay+=1; break;};
                   case 2:
                        {if(Nam%4==0) 
                                       if(Ngay==29) {Ngay=1; Thang=3;} else Ngay+=1;
                         else if(Ngay==28) {Ngay=1; Thang=3;} else Ngay+=1;
                        break;};         
                  }
                  return *this;
}
Date Date::Cong(int n){
          for(int i=0;i<n;i++)
          Cong();
}

/*int main(){
    Date a, b(34,3,1990), c(31,1,2000);
    cout<<"Date a: "; a.In();
    cout<<endl<<"Date b: "; b.In();
    cout<<endl<<"Date c: "; c.In();
    if(a.HopLe()) cout<<endl<<"Ngay a hop le"; 
    else cout<<endl<<"Ngay a khong hop le";
    if(b.HopLe()) cout<<endl<<"Ngay b hop le"; 
    else cout<<endl<<"Ngay b khong hop le";
    if(c.HopLe()) cout<<endl<<"Ngay c hop le"; 
    else cout<<endl<<"Ngay c khong hop le";
    cout<<endl<<"Date C sau khi cong them 1 ngay la: "; c.Cong(); c.In();
    int n;
    cout<<endl<<"Nhap so ngay cong vao C: "; cin>>n;
    cout<<"Date C sau khi cong them "<<n<<" ngay la: "; c.Cong(n); c.In();
    cout<<endl;
    system("pause");    
    return 0;
}*/
